package com.spring.springaop.test01;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;

@Aspect
public class LogAspects {

	@Pointcut("execution(public int com.spring.springaop.test01.MathCalculator.*(..))")
	public void pointCut(){};

	@Before("pointCut()")
	public void logStart(JoinPoint joinPoint){
		System.out.println(joinPoint.getSignature().getName()+"除法运行...参数是{}");
	}

	@After("pointCut(){}")
	public void logEnd(){
		System.out.println("除法结束");

	}

	@AfterReturning(value = "pointCut()",returning = "result")
	public void logReturn(Object result){
		System.out.println("除法正常返回。。。运行结果：{}"+result);
	}

	@AfterThrowing(value = "pointCut()",throwing = "ex")
	public void logException(JoinPoint joinPoint,Exception ex){
		System.out.println(joinPoint.getSignature().getName()+"异常：{}"+ex.getMessage());
	}
}
